package geektime.perf;

import java.util.ArrayList;

// java -Xmx20M -cp target/classes/ -XX:+HeapDumpOnOutOfMemoryError geektime.perf.OomTest
public class OomTest {

	public static int NUMBER = 10000000;
	public static boolean clear = false;
	
	public static void main(String[] args) {
		ArrayList<char[]> alist = new ArrayList<char[]>();
		for (int i = 0; i < NUMBER ; i++) {
			alist.add(new char[1000]);
			if (i % 100 == 0) {
				if (clear) {
					alist = new ArrayList<char[]>();
				}
				System.out.println("added " + i + " K char[]");
			}
		}
	}
}
